package cn.niu.dao;

import cn.niu.model.UserInfo;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserInfoMapper {
    @Delete({
        "delete from user_info",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into user_info (id, userName, ",
        "password, enabled, displayName, ",
        "content, sex, weChat, ",
        "weChatId, weChatAppId, ",
        "weChatWebId, weChatMicroAppId, ",
        "weChatUid, qq, qqId, ",
        "qqUid, email, mobile, ",
        "headImage, dateCreated, ",
        "dateLastVisit, citizenId, ",
        "isSetUserName, userType)",
        "values (#{id,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, ",
        "#{password,jdbcType=VARCHAR}, #{enabled,jdbcType=BIT}, #{displayName,jdbcType=VARCHAR}, ",
        "#{content,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{weChat,jdbcType=VARCHAR}, ",
        "#{weChatId,jdbcType=VARCHAR}, #{weChatAppId,jdbcType=VARCHAR}, ",
        "#{weChatWebId,jdbcType=VARCHAR}, #{weChatMicroAppId,jdbcType=VARCHAR}, ",
        "#{weChatUid,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{qqId,jdbcType=VARCHAR}, ",
        "#{qqUid,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, ",
        "#{headImage,jdbcType=VARCHAR}, #{dateCreated,jdbcType=TIMESTAMP}, ",
        "#{dateLastVisit,jdbcType=TIMESTAMP}, #{citizenId,jdbcType=VARCHAR}, ",
        "#{isSetUserName,jdbcType=BIT}, #{userType,jdbcType=INTEGER})"
    })
    int insert(UserInfo record);

    int insertSelective(UserInfo record);

    @Select({
        "select",
        "id, userName, password, enabled, displayName, content, sex, weChat, weChatId, ",
        "weChatAppId, weChatWebId, weChatMicroAppId, weChatUid, qq, qqId, qqUid, email, ",
        "mobile, headImage, dateCreated, dateLastVisit, citizenId, isSetUserName, userType",
        "from user_info",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("cn.niu.dao.UserInfoMapper.BaseResultMap")
    UserInfo selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(UserInfo record);

    @Update({
        "update user_info",
        "set userName = #{userName,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "enabled = #{enabled,jdbcType=BIT},",
          "displayName = #{displayName,jdbcType=VARCHAR},",
          "content = #{content,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "weChat = #{weChat,jdbcType=VARCHAR},",
          "weChatId = #{weChatId,jdbcType=VARCHAR},",
          "weChatAppId = #{weChatAppId,jdbcType=VARCHAR},",
          "weChatWebId = #{weChatWebId,jdbcType=VARCHAR},",
          "weChatMicroAppId = #{weChatMicroAppId,jdbcType=VARCHAR},",
          "weChatUid = #{weChatUid,jdbcType=VARCHAR},",
          "qq = #{qq,jdbcType=VARCHAR},",
          "qqId = #{qqId,jdbcType=VARCHAR},",
          "qqUid = #{qqUid,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "headImage = #{headImage,jdbcType=VARCHAR},",
          "dateCreated = #{dateCreated,jdbcType=TIMESTAMP},",
          "dateLastVisit = #{dateLastVisit,jdbcType=TIMESTAMP},",
          "citizenId = #{citizenId,jdbcType=VARCHAR},",
          "isSetUserName = #{isSetUserName,jdbcType=BIT},",
          "userType = #{userType,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(UserInfo record);
}